import 'package:p_location/alarm/obj/area/obj_info_detail.dart';

import 'obj_person_info.dart';

class ObjLackNumDetail {
  int areaId;
  String areaName;
  int currentNum;
  List<ObjPersonInfo> currentPersons;
  List<ObjPersonInfo> historyPersons;
  int lackNum;
  int overNum;
  int settingNum;
  List<ObjInfoDetail> inDetails;

  ObjLackNumDetail(
      {this.areaId,
      this.areaName,
      this.currentNum,
      this.currentPersons,
      this.historyPersons,
      this.lackNum,
      this.overNum,
      this.settingNum,
      this.inDetails});

  factory ObjLackNumDetail.fromJson(Map<String, dynamic> json) {
    return ObjLackNumDetail(
      areaId: json['areaId'],
      areaName: json['areaName'],
      currentNum: json['currentNum'],
      currentPersons: json['currentPersons'] != null
          ? (json['currentPersons'] as List)
              .map((i) => ObjPersonInfo.fromJson(i))
              .toList()
          : null,
      historyPersons: json['historyPersons'] != null
          ? (json['historyPersons'] as List)
              .map((i) => ObjPersonInfo.fromJson(i))
              .toList()
          : null,
      lackNum: json['lackNum'],
      overNum: json['overNum'],
      settingNum: json['settingNum'],
      inDetails: json['inDetails'] != null
          ? (json['inDetails'] as List)
              .map((i) => ObjInfoDetail.fromJson(i))
              .toList()
          : null,
    );
  }

  Map<String, dynamic> toJson() {
    final Map<String, dynamic> data = new Map<String, dynamic>();
    data['areaId'] = this.areaId;
    data['areaName'] = this.areaName;
    data['currentNum'] = this.currentNum;
    data['lackNum'] = this.lackNum;
    data['settingNum'] = this.settingNum;
    if (this.currentPersons != null) {
      data['currentPersons'] =
          this.currentPersons.map((v) => v.toJson()).toList();
    }
    if (this.historyPersons != null) {
      data['historyPersons'] =
          this.historyPersons.map((v) => v.toJson()).toList();
    }
    return data;
  }
}
